package online.longzipeng.householdbillssystem.common.utils;


import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @Author: lzp
 * @Date: 2021/2/8 12:58
 * 时间工具类
 */
public class DateUtils {

    private static SimpleDateFormat dfs = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    /**
     * 字符串转时间
     * @param parseString
     * @return
     */
    public static Date StringToDate(String parseString){
        Date date = new Date();
        try {
            date = dfs.parse(parseString);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return date;
    }

    /**
     * 时间转字符串
     * @param date
     * @return
     */
    public static String DateToString(Date date){
        return dfs.format(date);
    }

}
